package Ticketing.test03;

/**
 * @Author czl
 * @Date 2024-03-20
 */
public class Cinema implements Runnable{

    private int piao = 50;



    @Override
    public void run() {
        while (piao >=1){
            sell();
        }
    }

    private synchronized void sell()  {
        if (piao>0){
            System.out.println(Thread.currentThread().getName()+"出售了第" + piao + "张票");
            piao--;
        }

        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

}
